


function submits(obj) {
    $.ajax({
        url:keyurl,
        type:"post",
        dataType:"text",
        data:{
            name:obj.value
        },
        success:function (data) {
            // alert(data)                                     //测试data
            if(data=="1"){                                 //判断是否成功
               $("#span").text("这个名字已经存在了")
                // alert(  $("#span").text())  //测试代码
            }else{
                $("#span").text(" ")
            }
        },
        error:function (e) {
            alert(e.response)
        }
    });
}
function submit() {
    if($("#span").text()!=""){
    $.ajax({
        url:url,
        type:"post",
        dataType:"text",
        data:$("#forms").serialize(),
        success:function (data) {
            // alert(data)                                     //测试data
            if(data=="1"){                                 //判断是否成功
                alert("添加成功")
                location.href=lurl;
            }else{
                alert("添加失败")
            }
        },
        error:function (e) {
            alert(e.response)
        }
    });
    }else {
        return false;
    }
}
$.validator.setDefaults({
    submitHandler: function() {
        submit()
    }
});
$(function () {
    $("#forms").validate({
        rules: {
            name: {
                required: true,
                maxlength: 24
            }
        },
        messages: {
            name: {
                required: "这个是不能为空"
            }

        }
    });



})/**
 * Created by Administrator on 2017/7/18.
 */
